Java Object Size
Java Object Size
To get the object size, YourKit Profiler v9.0.2 is used and for SimpleClass, shallow sizes are used.
public class SimpleClass {
public int x;
}
For 32bit Java, the size of the object is 16 bytes.
For 64bit Java, size is 24 bytes
public class SimpleClass {
public int x;
public int y;
}
32bit Java -> 16 bytes. 64bit Java -> 24bytes.
public class SimpleClass {
public int x;
public int y;
public int z;
}
32bit Java -> 24 bytes. 64bit Java -> 32 bytes.
http://javaquirks.blogspot.com/2008/03/it-gets-worse.html
______32-bit 64-bit
Object 8 16
Integer 16 24
Long 16 24
Float 16 24
Double 16 24
String 40 64
Date 24 32
Calendar 432 544
byte[0] 16 24
byte[32] 48 56
byte[128][0] 2576 4120
ArrayList(1) 56 96
ArrayList(2) 80 128
Subscribe to Lydon's blog
Get the latest posts delivered right to your inbox